var verify = {}
// 判断是否为空
verify.isNull = (value) =>{
    var flag = false
    if( typeof value === 'number' ){
      flag = false
    }else if(value === null || value.length < 1  ||  value === 'undefined'){
      flag = true
    } else {
      flag = false
    }
    return flag
}

// 特殊字符验证
verify.isSpecial = (value) =>{
  const special = /[\!\@\#\$\%\^\&\*~<>',\.]/
  return special.test(value)
}
// 长度限制
verify.lengthLimit = (value, minlen,maxlen) => {
  var flag = false
  if (value.length > maxlen || value.length < minlen) {
    flag = false
  } else {
    flag = true
  }
  return flag
}
// 判断银行卡号是否正确
verify.isBankCard = (value) => {
  const bankCard = /^[0-9]{16,19}$/
  return bankCard.test(value)
}
// 判断邮编是否正确
verify.isPostode = (value) => {
  const postCode = /^\d{6}$/
  return postCode.test(value)
}

// 判断电话号码是否正确
verify.isMobile = (value) => {
  const mobile = /^1[3-9]\d{9}$/
  const mobile1 = /^\d{3,4}[-]\d{8}$/
  return mobile.test(value) || mobile1.test(value)
}
// 判断是否为MP3文件
verify.isMp3 = (value) => {
  const flag =
    value.substring(value.lastIndexOf('.') + 1).toLowerCase() === 'mp3'
  return flag
}
// 判断身份证号是否正确\
verify.isIdCard = (value) => {
  const idCard = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
  return idCard.test(value)
}
// 判断邮箱是否正确
verify.isEMail = (value) => {
  const mail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/
  return mail.test(value)
}
// 判断护照是否正确
verify.isPassport = (value) => {
  const passport = /^([EK]\d{8}|(SE|DE|PE|MA)\d{7})$/
  return passport.test(value)
}
// 判断车牌号是否正确
verify.isCarNo = (value) => {
  const carNo = /(^[\u4E00-\u9FA5]{1}[A-Z0-9]{6}$)|(^[A-Z]{2}[A-Z0-9]{2}[A-Z0-9\u4E00-\u9FA5]{1}[A-Z0-9]{4}$)|(^[\u4E00-\u9FA5]{1}[A-Z0-9]{5}[挂学警军港澳]{1}$)|(^[A-Z]{2}[0-9]{5}$)|(^(08|38){1}[A-Z0-9]{4}[A-Z0-9挂学警军港澳]{1}$)/
  return carNo.test(value)
}
// 判断车架号是否正确
verify.isChassisNumber = (value) => {
  const chassisNumber = /^[A-HJ-NPR-Z\d]{8}[X\d][A-HJ-NPR-Z\d]{3}\d{5}$/
  return chassisNumber.test(value)
}

export default verify
